package org.budo.poi;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.PictureData;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;

import lombok.Getter;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * @author lmw
 * @see org.apache.poi.hssf.usermodel.HSSFWorkbook
 */
@Getter
public class AbstractWorkbook implements Workbook {
    private Map<String, Sheet> sheets = new LinkedHashMap<String, Sheet>();

    @Override
    public Sheet getSheetAt(int index) {
        Iterator<Entry<String, Sheet>> iterator = sheets.entrySet().iterator();

        for (int i = 0; i < index; i++) {
            iterator.next();
        }

        return iterator.next().getValue();
    }

    @Override
    public String toString() {
        return super.toString() + ", sheets=" + this.sheets;
    }

    @Override
    public int getActiveSheetIndex() {
        throw new RuntimeException();
    }

    @Override
    public void setActiveSheet(int sheetIndex) {
        throw new RuntimeException();
    }

    @Override
    public int getFirstVisibleTab() {
        throw new RuntimeException();
    }

    @Override
    public void setFirstVisibleTab(int sheetIndex) {
        throw new RuntimeException();
    }

    @Override
    public void setSheetOrder(String sheetname, int pos) {
        throw new RuntimeException();
    }

    @Override
    public void setSelectedTab(int index) {
        throw new RuntimeException();
    }

    @Override
    public void setSheetName(int sheet, String name) {
        throw new RuntimeException();
    }

    @Override
    public String getSheetName(int sheet) {
        throw new RuntimeException();
    }

    @Override
    public int getSheetIndex(String name) {
        throw new RuntimeException();
    }

    @Override
    public int getSheetIndex(Sheet sheet) {
        throw new RuntimeException();
    }

    @Override
    public Sheet createSheet() {
        throw new RuntimeException();
    }

    @Override
    public Sheet cloneSheet(int sheetNum) {
        throw new RuntimeException();
    }

    @Override
    public int getNumberOfSheets() {
        throw new RuntimeException();
    }

    @Override
    public Sheet getSheet(String name) {
        throw new RuntimeException();
    }

    @Override
    public void removeSheetAt(int index) {
        throw new RuntimeException();
    }

    @Override
    public void setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow) {
        throw new RuntimeException();
    }

    @Override
    public Font createFont() {
        throw new RuntimeException();
    }

    @Override
    public Font findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
        throw new RuntimeException();
    }

    @Override
    public short getNumberOfFonts() {
        throw new RuntimeException();
    }

    @Override
    public Font getFontAt(short idx) {
        throw new RuntimeException();
    }

    @Override
    public CellStyle createCellStyle() {
        throw new RuntimeException();
    }

    @Override
    public short getNumCellStyles() {
        throw new RuntimeException();
    }

    @Override
    public CellStyle getCellStyleAt(short idx) {
        throw new RuntimeException();
    }

    @Override
    public int getNumberOfNames() {
        throw new RuntimeException();
    }

    @Override
    public Name getName(String name) {
        throw new RuntimeException();
    }

    @Override
    public Name getNameAt(int nameIndex) {
        throw new RuntimeException();
    }

    @Override
    public Name createName() {
        throw new RuntimeException();
    }

    @Override
    public int getNameIndex(String name) {
        throw new RuntimeException();
    }

    @Override
    public void removeName(int index) {
        throw new RuntimeException();
    }

    @Override
    public void removeName(String name) {
        throw new RuntimeException();
    }

    @Override
    public void setPrintArea(int sheetIndex, String reference) {
        throw new RuntimeException();
    }

    @Override
    public void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow) {
        throw new RuntimeException();
    }

    @Override
    public String getPrintArea(int sheetIndex) {
        throw new RuntimeException();
    }

    @Override
    public void removePrintArea(int sheetIndex) {
        throw new RuntimeException();
    }

    @Override
    public MissingCellPolicy getMissingCellPolicy() {
        throw new RuntimeException();
    }

    @Override
    public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
        throw new RuntimeException();
    }

    @Override
    public DataFormat createDataFormat() {
        throw new RuntimeException();
    }

    @Override
    public int addPicture(byte[] pictureData, int format) {
        throw new RuntimeException();
    }

    @Override
    public List<? extends PictureData> getAllPictures() {
        throw new RuntimeException();
    }

    @Override
    public CreationHelper getCreationHelper() {
        throw new RuntimeException();
    }

    @Override
    public boolean isHidden() {
        throw new RuntimeException();
    }

    @Override
    public void setHidden(boolean hiddenFlag) {
        throw new RuntimeException();
    }

    @Override
    public boolean isSheetHidden(int sheetIx) {
        throw new RuntimeException();
    }

    @Override
    public boolean isSheetVeryHidden(int sheetIx) {
        throw new RuntimeException();
    }

    @Override
    public void setSheetHidden(int sheetIx, boolean hidden) {
        throw new RuntimeException();
    }

    @Override
    public void setSheetHidden(int sheetIx, int hidden) {
        throw new RuntimeException();
    }

    @Override
    public void addToolPack(UDFFinder toopack) {
        throw new RuntimeException();
    }

    @Override
    public void setForceFormulaRecalculation(boolean value) {
        throw new RuntimeException();
    }

    @Override
    public boolean getForceFormulaRecalculation() {
        throw new RuntimeException();
    }

    @Override
    public void write(OutputStream stream) throws IOException {
        throw new RuntimeException();
    }

    @Override
    public Sheet createSheet(String sheetname) {
        throw new RuntimeException();
    }
}